package com.feishi.core.util.pdf;



//import com.spire.pdf.*;
//import java.awt.geom.Rectangle2D;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.rendering.PDFRenderer;

import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: caixq
 * Date: 2020-08-20
 * Time: 下午4:14
 */
public class PDFUtil {


    public static void main(String[] args) throws IOException {

////实例化PdfDocument类的对象，并加载测试文档
//        PdfDocument doc = new PdfDocument();
//        doc.loadFromFile("/home/caixq/Downloads/test.pdf");
//
////获取文档第1页
//        PdfPageBase page = doc.getPages().get(0);
//
////加载图片，设置为背景水印
//        page.setBackgroundImage("/home/caixq/Downloads/logo.png");
//
////指定水印在文档中的位置及图片大小
//        Rectangle2D.Float rect = new Rectangle2D.Float();
//        rect.setRect(150, 150, 300, 150);
//        page.setBackgroundRegion(rect);
//
////保存文档
//        doc.saveToFile("/home/caixq/Downloads/输出.pdf");
//        doc.close();
        PDDocument document = PDDocument.load(new File("/home/caixq/Downloads/test.pdf"));
        int pages = document.getNumberOfPages();
        PDPage page0 = document.getPage(0);
        PDFRenderer renderer = new PDFRenderer(document);


    }
}
